package com.dyh.quickdemozwei.thewd;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: yhdong
 * @Date: 2021/12/17 11:42
 */
@Slf4j
@Configuration
public class WatchDogConfig {

    @Autowired
    FooService fooService;

    @Bean
    WatchDog watchDog(){
        WatchDog watchDog = new WatchDog();
//        watchDog.start();
        return watchDog;
    }

    class WatchDog extends Thread{
        @Override
        public void run() {
            for (;;){
                try {
                    Thread.sleep(1000L);
                    fooService.foo();
                } catch (InterruptedException e) {
                    log.error("e=",e);
                }
            }
        }
    }

}
